<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    table {
        border: solid;
    }

    td {
        border: solid 1px;
    }

    input {
        width: 20px;
        height: 20px;
    }
</style>

<body>
    <table>
        <thead>
            <tr>
                <td><input type="checkbox" id="all"></td>
                <td>成绩</td>
                <td>排名</td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="checkbox"></td>
                <td>99</td>
                <td>1</td>
            </tr>
            <tr>
                <td><input type="checkbox"></td>
                <td>89</td>
                <td>2</td>
            </tr>
            <tr>
                <td><input type="checkbox"></td>
                <td>88</td>
                <td>3</td>
            </tr>
            <tr>
                <td><input type="checkbox"></td>
                <td>77</td>
                <td>4</td>
            </tr>
            <tr>
                <td><input type="checkbox"></td>
                <td>60</td>
                <td>5</td>
            </tr>
        </tbody>
    </table>
    <script>
        var all = document.getElementById("all");
        var singles = document.querySelector("tbody").querySelectorAll("input");
        all.onclick = function () {

            for (var i = 0; i < singles.length; i++) {
                singles[i].checked = this.checked;
            }

        }
        for (var i = 0; i < singles.length; i++) {
            singles[i].onclick = function () {
                var flag = 1;
                for (var j = 0; j < singles.length; j++) {
                    if (!singles[j].checked) {
                        flag = 0;
                    }
                }
                if (flag) {
                    all.checked = true;
                } else {
                    all.checked = false;
                }
            }
        }
    </script>
</body>

</html>